<?php
class Admin_Form_User extends Zend_Form
{
    public function init()
    {
        $this->setName("admin");

        $userId = new Zend_Form_Element_Hidden('userId');
        $userId->addFilter('Int');
        
        $username = new Zend_Form_Element_Text('username');
        $username->setLabel('Tên đăng nhập')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
        $username->setAttrib('size', 60);
        
        $email = new Zend_Form_Element_Text('email');
        $email->setLabel('Email')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty')->addValidator('EmailAddress');
        $email->setAttrib('size', 60);
        $password = new Zend_Form_Element_Password('password');
        $password->setLabel('Mật khẩu')->addFilter('StripTags')->addFilter('StringTrim');
        $password->setAttrib('size', 20);
                
        $mobile = new Zend_Form_Element_Text('mobile');
        $mobile->setLabel('Di động')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
        $mobile->setAttrib('size', 20);
        
        $phone = new Zend_Form_Element_Text('phone');
        $phone->setLabel('Điện thoại bàn')->addFilter('StripTags')->addFilter('StringTrim');
        $phone->setAttrib('size', 20);
                
        $fullname = new Zend_Form_Element_Text('fullname');
        $fullname->setLabel('Tên đầy đủ')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
        $fullname->setAttrib('size', 60);
        
        $birth= new Zend_Form_Element_Text('birth');
        $birth->setLabel('Ngày sinh')->addFilter('StripTags')->addFilter('StringTrim');
        $birth->setAttrib('size', 20)
            ->setAttrib('id','datepicker')->setAttrib('placeholder','yyyy-mm-dd')->setAttrib('readonly','');                    
        
        $sex = new Zend_Form_Element_Select('sex');
        $sex->setLabel('Giới tính');
        $sex->addMultiOption('0','Nam');
        $sex->addMultiOption('1','Nữ');
        
        $address = new Zend_Form_Element_Text('address');
        $address->setLabel('Địa chỉ')->addFilter('StripTags')->addFilter('StringTrim');
        $address->setAttrib('size', 60);
        
        $role = new Zend_Form_Element_Select('role');
        $role->setLabel('Loại tài khoản');
        $role->addMultiOption('0','Tài khoản cá nhân');
        $role->addMultiOption('1','Tài khoản doanh nghiệp');
                        
        $status = new Zend_Form_Element_Select('status');
        $status->setLabel('Trạng thái');
        $status->addMultiOption('1','Đang hoạt động');
        $status->addMultiOption('0','Tạm khóa');

        $avatar=new Zend_Form_Element_File('avatar');
        $avatar->setLabel('Thay đổi hình đại diện');
        $avatar->addValidator('Extension',true,array('jpg','gif','png'),'picture');                 
        $avatar->addValidator('Size',true,array('min'=>'0KB','max'=>'5KB'),'picture');
        $avatar->setAttrib('size', 60);

        $gold = new Zend_Form_Element_Text('gold');
        $gold->setLabel('Tiền trong tài khoản')->addFilter('StripTags')->addFilter('StringTrim')->addFilter('Int');
        $gold->setAttrib('size', 20);

        // submit button
        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setAttrib('id','submitbutton');
        $submit->setAttrib('class',"button medium");

        // add elements to form
        $this->addElements(array (
            $userId, $username, $email, $mobile, $password, $fullname, $birth, $sex, $phone, $address, $avatar, $role, $status, $gold, $submit
        ));
    }
}